export module read_line;
#include<stdio.h>
#include<stdlib.h>
#include<sys/types.h>
#include<sys/stat.h>
#include<fcntl.h>
#include<string.h>
#include<unistd.h>


int read_Line(int fd,void *buffer,size_t buff_len)
{
    int r_c;
    int i = 0;
    memset(buffer,0,buff_len);
    char *buff=(char *)buffer;
    char temp;
    while ( (r_c = read(fd,&temp,1)) >= 0)
    {
        if(i>=buff_len)
        {
            return buff_len;
        }
        if(r_c = 0)
        {
            return 0;
        }
        else if(temp == '\n')
        {
            buff[i]='\0';
            return i;
        }
        else{
            buff[i]=temp;
        }
        i++;
        
    }
    return -1;
}